home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1997 August
/
Walnut Creek CDROM.7z
/
LISTINGS
/
V_13_04
/
ALLISON.ZIP
/
CONVERT3.CPP
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
1995-02-07
|
413 b
|
36 lines
LISTING 3 - Illustrates an implicit user-defined conversion
// convert3.cpp
#include <iostream.h>
struct A
{
double x;
A(double d)
{
cout << "A::A(double)" << endl;
x = d;
}
};
void f(const A& a)
{
cout << "f: " << a.x << endl;
}
main()
{
A a(1);
f(a);
f(2);
return 0;
}
// Output:
A::A(double)
f: 1
A::A(double)
f: 2